﻿using PRO.Admin;
using PRO.Product;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PRO.Common;

namespace web.Manage.ProductClass
{
    public partial class _default : ManageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }

        private void Bind()
        {
            DataTable dt = ClassLib.GetOurClassTree();
            this.Repeater1.DataSource = dt;
            this.Repeater1.DataBind();
        }
        protected void SortControl1_SortCallBack(object sender, EventArgs e)
        {
            Bind();
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int id = e.CommandArgument.ToString().ToInt(0);
            if (id == 0)
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('参数移除！');</script>");
            else
            {
                string msg = null;
                if (ClassLib.DelClass(id, out msg))
                {
                    Bind();
                }
                else
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('" + msg + "');</script>");
            }
        }
    }
}